package com.pri.chat.nim.session.extension;

import com.alibaba.fastjson.JSONObject;

/**
 * 自定义分享
 * @author mhd
 */
public class ShareAttachment extends CustomAttachment {
    private final String KEY_DESCRIBE = "describe";
    private final String KEY_IMAGE_URL = "image_url";
    private final String KEY_TITLE = "key_title";
    private final String KEY_TYPE = "key_type";
    private final String KEY_ID = "key_id";

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    // 图文消息的描述，可以为空
    private String describe;
    // 图文消息的图片
    private String imageUrl;
    // 标题
    private String title;

    private int type;

    private String id;

    public ShareAttachment() {
        super(CustomAttachmentType.Share);
    }

    @Override
    protected void parseData(JSONObject data) {
        describe = data.getString(KEY_DESCRIBE);
        imageUrl = data.getString(KEY_IMAGE_URL);
        title = data.getString(KEY_TITLE);
        type = data.getInteger(KEY_TYPE);
        id = data.getString(KEY_ID);
    }

    @Override
    protected JSONObject packData() {
        JSONObject data = new JSONObject();
        data.put(KEY_DESCRIBE, getDescribe());
        data.put(KEY_IMAGE_URL, getImageUrl());
        data.put(KEY_TITLE,getTitle());
        data.put(KEY_TYPE,getType());
        data.put(KEY_ID,getId());
        return data;
    }
}
